package com.xuecheng.content.controller;

import com.xuecheng.api.content.TeachplanMediaApi;
import com.xuecheng.api.media.model.dto.TeachplanMediaDTO;
import com.xuecheng.api.media.model.vo.BindTeachplanMediaVO;
import com.xuecheng.common.util.SecurityUtil;
import com.xuecheng.content.convert.TeachplanMediaConvert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.xuecheng.content.service.TeachplanMediaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author itcast
 */
@Slf4j
@RestController
//@RequestMapping("teachplanMedia")
public class TeachplanMediaController implements TeachplanMediaApi {

    @Autowired
    private TeachplanMediaService  teachplanMediaService;


    @PostMapping("/teachplan/media/association")
    public TeachplanMediaDTO associateMedia(@RequestBody BindTeachplanMediaVO vo) {

        Long companyId = SecurityUtil.getCompanyId();

        TeachplanMediaDTO teachplanMediaDTO = TeachplanMediaConvert.INSTANCE.vo2dto(vo);

        TeachplanMediaDTO dto = teachplanMediaService.associateMedia(teachplanMediaDTO, companyId);

        return dto;
    }
}
